/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is Forte for Java, Community Edition. The Initial
* Developer of the Original Code is Sun Microsystems, Inc. Portions
* Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.javadoc.comments;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.ButtonGroup;
import org.openide.src.MemberElement;
import org.openide.src.ConstructorElement;
import org.openide.src.FieldElement;
import org.openide.src.ClassElement;
import org.openide.src.JavaDocTag;
import org.openide.src.JavaDocSupport;
/**
*
* @author
* @version
*/
public class NewTagDialog extends javax.swing.JDialog implements JavaTagNames {
private ButtonGroup bgroup;
private JavaDocTag result = null;
private MemberElement element;
private String TAG_CUSTOM = "@"; // NOI18N
static final long serialVersionUID =8648611535888090920L;
/** Initializes the Form */
public NewTagDialog(java.awt.Frame parent, boolean modal, MemberElement element ) {
super (parent, modal);
initComponents ();
this.element = element;
bgroup = new ButtonGroup();
bgroup.add( authorRadioButton );
authorRadioButton.getModel().setActionCommand( TAG_AUTHOR );
authorRadioButton.setVisible( false );
bgroup.add( deprecatedRadioButton );
deprecatedRadioButton.getModel().setActionCommand( TAG_DEPRECATED );
bgroup.add( paramRadioButton );
paramRadioButton.getModel().setActionCommand( TAG_PARAM );
paramRadioButton.setVisible( false );
bgroup.add( returnRadioButton );
returnRadioButton.getModel().setActionCommand( TAG_RETURN );
returnRadioButton.setVisible( false );
bgroup.add( seeRadioButton );
seeRadioButton.getModel().setActionCommand( TAG_SEE );
bgroup.add( serialRadioButton );
serialRadioButton.getModel().setActionCommand( TAG_SERIAL );
serialRadioButton.setVisible( false );
bgroup.add( serialDataRadioButton );
serialDataRadioButton.getModel().setActionCommand( TAG_SERIALDATA );
serialDataRadioButton.setVisible( false );
bgroup.add( serialFieldRadioButton );
serialFieldRadioButton.getModel().setActionCommand( TAG_SERIALFIELD );
serialFieldRadioButton.setVisible( false );
bgroup.add( sinceRadioButton );
sinceRadioButton.getModel().setActionCommand( TAG_SINCE );
bgroup.add( throwsRadioButton );
throwsRadioButton.getModel().setActionCommand( TAG_THROWS );
throwsRadioButton.setVisible( false );
bgroup.add( versionRadioButton );
versionRadioButton.getModel().setActionCommand( TAG_VERSION );
versionRadioButton.setVisible( false );
bgroup.add( customRadioButton );
customRadioButton.getModel().setActionCommand( TAG_CUSTOM );
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dialogSize = this.getSize();
this.setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
if ( element instanceof ConstructorElement ) {
paramRadioButton.setVisible( true );
returnRadioButton.setVisible( true );
serialDataRadioButton.setVisible( true );
throwsRadioButton.setVisible( true );
}
else if ( element instanceof FieldElement ) {
serialRadioButton.setVisible( true );
serialFieldRadioButton.setVisible( true );
}
if ( element instanceof ClassElement ) {
authorRadioButton.setVisible( true );
versionRadioButton.setVisible( true );
}
pack ();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the FormEditor.
*/
private void initComponents () {//GEN-BEGIN:initComponents
jPanel2 = new javax.swing.JPanel ();
authorRadioButton = new javax.swing.JRadioButton ();
deprecatedRadioButton = new javax.swing.JRadioButton ();
paramRadioButton = new javax.swing.JRadioButton ();
returnRadioButton = new javax.swing.JRadioButton ();
seeRadioButton = new javax.swing.JRadioButton ();
serialRadioButton = new javax.swing.JRadioButton ();
serialDataRadioButton = new javax.swing.JRadioButton ();
serialFieldRadioButton = new javax.swing.JRadioButton ();
sinceRadioButton = new javax.swing.JRadioButton ();
throwsRadioButton = new javax.swing.JRadioButton ();
versionRadioButton = new javax.swing.JRadioButton ();
customRadioButton = new javax.swing.JRadioButton ();
customTextField = new javax.swing.JTextField ();
jPanel3 = new javax.swing.JPanel ();
okButton = new javax.swing.JButton ();
cancelButton = new javax.swing.JButton ();
setTitle (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.Form.title"));
addWindowListener (new java.awt.event.WindowAdapter () {
public void windowClosing (java.awt.event.WindowEvent evt) {
closeDialog (evt);
}
}
);
jPanel2.setLayout (new java.awt.GridBagLayout ());
java.awt.GridBagConstraints gridBagConstraints1;
jPanel2.setBorder (new javax.swing.border.EmptyBorder(new java.awt.Insets(8, 8, 8, 8)));
authorRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.authorRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (authorRadioButton, gridBagConstraints1);
deprecatedRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.deprecatedRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (deprecatedRadioButton, gridBagConstraints1);
paramRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.paramRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (paramRadioButton, gridBagConstraints1);
returnRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.returnRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (returnRadioButton, gridBagConstraints1);
seeRadioButton.setSelected (true);
seeRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.seeRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (seeRadioButton, gridBagConstraints1);
serialRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.serialRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (serialRadioButton, gridBagConstraints1);
serialDataRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.serialDataRadioButton.text"));
serialDataRadioButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
serialDataRadioButtonActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (serialDataRadioButton, gridBagConstraints1);
serialFieldRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.serialFieldRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (serialFieldRadioButton, gridBagConstraints1);
sinceRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.sinceRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (sinceRadioButton, gridBagConstraints1);
throwsRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.throwsRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (throwsRadioButton, gridBagConstraints1);
versionRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.versionRadioButton.text"));
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (versionRadioButton, gridBagConstraints1);
customRadioButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("NewTagDialog.customRadioButton.text"));
customRadioButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
customRadioButtonActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = -1;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (customRadioButton, gridBagConstraints1);
customTextField.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
customTextFieldActionPerformed (evt);
}
}
);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
jPanel2.add (customTextField, gridBagConstraints1);
jPanel3.setLayout (new java.awt.GridLayout (1, 2));
jPanel3.setBorder (new javax.swing.border.EmptyBorder(new java.awt.Insets(6, 1, 1, 1)));
okButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("CTL_NewTagDialog.okButton.text"));
okButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
okButtonActionPerformed (evt);
}
}
);
jPanel3.add (okButton);
cancelButton.setText (org.openide.util.NbBundle.getBundle(NewTagDialog.class).getString("CTL_NewTagDialog.cancelButton.text"));
cancelButton.addActionListener (new java.awt.event.ActionListener () {
public void actionPerformed (java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed (evt);
}
}
);
jPanel3.add (cancelButton);
gridBagConstraints1 = new java.awt.GridBagConstraints ();
gridBagConstraints1.gridwidth = 0;
gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL;
jPanel2.add (jPanel3, gridBagConstraints1);
getContentPane ().add (jPanel2, java.awt.BorderLayout.CENTER);
}//GEN-END:initComponents
private void cancelButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
// Add your handling code here:
result = null;
closeDialog( null );
}//GEN-LAST:event_cancelButtonActionPerformed
private void okButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
// Add your handling code here:
String command = bgroup.getSelection().getActionCommand();
if ( command.equals( TAG_SEE ) ) {
result = JavaDocSupport.createSeeTag( command, "" ); // NOI18N
}
else if ( command.equals( TAG_PARAM ) ) {
result = JavaDocSupport.createParamTag( command, "" ); // NOI18N
}
else if ( command.equals( TAG_THROWS ) ) {
result = JavaDocSupport.createThrowsTag( command, "" ); // NOI18N
}
else if ( command.equals( TAG_SERIALFIELD ) ) {
result = JavaDocSupport.createSerialFieldTag( command, " " ); // NOI18N
}
else if ( command.equals( TAG_CUSTOM ) ) {
result = JavaDocSupport.createTag( command + customTextField.getText(), "" ); // NOI18N
}
else {
result = JavaDocSupport.createTag( command, "" ) ; // NOI18N
}
closeDialog( null );
}//GEN-LAST:event_okButtonActionPerformed
private void serialDataRadioButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_serialDataRadioButtonActionPerformed
// Add your handling code here:
}//GEN-LAST:event_serialDataRadioButtonActionPerformed
private void customTextFieldActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customTextFieldActionPerformed
// Add your handling code here:
}//GEN-LAST:event_customTextFieldActionPerformed
private void customRadioButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customRadioButtonActionPerformed
// Add your handling code here:
}//GEN-LAST:event_customRadioButtonActionPerformed
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
setVisible (false);
dispose ();
}//GEN-LAST:event_closeDialog
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel jPanel2;
private javax.swing.JRadioButton authorRadioButton;
private javax.swing.JRadioButton deprecatedRadioButton;
private javax.swing.JRadioButton paramRadioButton;
private javax.swing.JRadioButton returnRadioButton;
private javax.swing.JRadioButton seeRadioButton;
private javax.swing.JRadioButton serialRadioButton;
private javax.swing.JRadioButton serialDataRadioButton;
private javax.swing.JRadioButton serialFieldRadioButton;
private javax.swing.JRadioButton sinceRadioButton;
private javax.swing.JRadioButton throwsRadioButton;
private javax.swing.JRadioButton versionRadioButton;
private javax.swing.JRadioButton customRadioButton;
private javax.swing.JTextField customTextField;
private javax.swing.JPanel jPanel3;
private javax.swing.JButton okButton;
private javax.swing.JButton cancelButton;
// End of variables declaration//GEN-END:variables
public static void main(java.lang.String[] args) {
new NewTagDialog (new java.awt.Frame (), false, null).show ();
}
JavaDocTag getResult() {
return result;
}
}
/*
* Log
* 5 Gandalf 1.4 1/12/00 Petr Hrebejk i18n
* 4 Gandalf 1.3 11/27/99 Patrik Knakal
* 3 Gandalf 1.2 10/23/99 Ian Formanek NO SEMANTIC CHANGE - Sun
* Microsystems Copyright in File Comment
* 2 Gandalf 1.1 9/16/99 Petr Hrebejk Tag descriptions editing
* in HTML editor + localization
* 1 Gandalf 1.0 7/9/99 Petr Hrebejk
* $
*/